/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "risk_assessment")
@NamedQueries({
    @NamedQuery(name = "RiskAssessment.findAll", query = "SELECT r FROM RiskAssessment r"),
    @NamedQuery(name = "RiskAssessment.findByRaId", query = "SELECT r FROM RiskAssessment r WHERE r.raId = :raId"),
    @NamedQuery(name = "RiskAssessment.findByRaValue", query = "SELECT r FROM RiskAssessment r WHERE r.raValue = :raValue"),
    @NamedQuery(name = "RiskAssessment.findByRaLevel", query = "SELECT r FROM RiskAssessment r WHERE r.raLevel = :raLevel")})
public class RiskAssessment implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ra_id")
    private Integer raId;
    @Basic(optional = false)
    @Column(name = "ra_value")
    private int raValue;
    @Basic(optional = false)
    @Column(name = "ra_level")
    private String raLevel;
    @JoinColumn(name = "ri_id", referencedColumnName = "ri_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private RiskItem riskItem;

    public RiskAssessment() {
    }

    public RiskAssessment(Integer raId) {
        this.raId = raId;
    }

    public RiskAssessment(Integer raId, int raValue, String raLevel) {
        this.raId = raId;
        this.raValue = raValue;
        this.raLevel = raLevel;
    }

    public Integer getRaId() {
        return raId;
    }

    public void setRaId(Integer raId) {
        this.raId = raId;
    }

    public int getRaValue() {
        return raValue;
    }

    public void setRaValue(int raValue) {
        this.raValue = raValue;
    }

    public String getRaLevel() {
        return raLevel;
    }

    public void setRaLevel(String raLevel) {
        this.raLevel = raLevel;
    }

    public RiskItem getRiskItem() {
        return riskItem;
    }

    public void setRiskItem(RiskItem riskItem) {
        this.riskItem = riskItem;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (raId != null ? raId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RiskAssessment)) {
            return false;
        }
        RiskAssessment other = (RiskAssessment) object;
        if ((this.raId == null && other.raId != null) || (this.raId != null && !this.raId.equals(other.raId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.RiskAssessment[raId=" + raId + "]";
    }

}
